<template>
	<view>
		<!-- 没有订单时的卡片 -->
		<view v-if="status == '0'">
			<text>今日还没有下单</text>
		</view>
		<!-- 有订单时的卡片 -->
		<view v-else-if="status == '1'" class="cu-list menu" :class="[menuBorder?'sm-border':'',menuCard?'card-menu margin-top':'']">
		
			<view v-for="(item,index) in list" :key="index" class="cu-item" @click="openOrder(item.order.id,item.site.id)">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-peoplefill text-blue margin-right-xs">{{item.site.name}}</text></view>
					<view class="text-gray text-sm">
						<text class="cuIcon-locationfill margin-right-xs">{{item.site.location}}</text></view>
				</view>
				<view class="action">
					<text class="cuIcon-timefill margin-right-xs"></text>{{item.order.reserve_time}}</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				orderList:[],
				status:'',
				list:[]
			}
		},
		onLoad() {
	
		},
		// 监听页面显示
		onShow() {
			this.allOrder();
		},
		methods: {
			allOrder(){
				this.$H.get('/order/orders/get-orders').then(res=>{
					let [err,result] = res;
					if(result.data.code == '200'){
						this.orderList = result.data.data;
						this.status = '1';
						for(let i=0;i<this.orderList.length;i++){
							this.$H.get('/order/site/get-siteone/'+this.orderList[i].user_location).then(res=>{
								let [err,result] = res;
								if(result.data.code == '200'){
									let item={"order":this.orderList[i],"site":result.data.data}
									this.list.push(item)
									return;
								}
								
							})
						}
						
						return;
					}
					if(result.data.code == '402'){
						this.status = '0';
					}
				})
			},
			// 跳转到订单详情,携带用户状态和订单id
			openOrder(orderid,siteid){
				uni.navigateTo({
					url: 'orderdetail?orderid='+orderid+'&siteid='+siteid,
					animationType: 'slide-in-right',
					//animationDuration: '200'
				})
			}
		}
	}
</script>

<style>
</style>
